import { getPersons } from "@/services/person"

export default {
  namespace: "person",
  state: {
    persons: []
  },
  effects: {
    *fetchPersons(_: any, { call, put }: any) {
      const data = yield call(getPersons);
      yield put({
        type: "setPersons",
        payload: data,
      })
    }
  },
  reducers: {
    setPersons(state: any, action: any) {
      return {
        ...state,
        persons: action.payload
      }
    }
  }
}